// Copyright (c) 2024 CHANGLEI. All rights reserved.

import 'package:charts_grasp/src/chart/utils/enum.dart';
import 'package:charts_grasp/src/common/utils/enum.dart';
import 'package:flutter/material.dart';

@immutable
class CartesianChartAnnotation {
  const CartesianChartAnnotation({
    this.widget,
    this.coordinateUnit = CoordinateUnit.logicalPixel,
    this.region = AnnotationRegion.chart,
    this.horizontalAlignment = ChartAlignment.center,
    this.verticalAlignment = ChartAlignment.center,
    this.x = 0,
    this.y = 0,
    this.xAxisName,
    this.yAxisName,
  });

  final Widget? widget;

  final CoordinateUnit coordinateUnit;

  final AnnotationRegion region;

  final dynamic x;

  final dynamic y;

  final String? xAxisName;

  final String? yAxisName;

  final ChartAlignment horizontalAlignment;

  final ChartAlignment verticalAlignment;

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }

    return other is CartesianChartAnnotation &&
        other.widget == widget &&
        other.coordinateUnit == coordinateUnit &&
        other.region == region &&
        other.horizontalAlignment == horizontalAlignment &&
        other.verticalAlignment == verticalAlignment &&
        other.x == x &&
        other.y == y &&
        other.xAxisName == xAxisName &&
        other.yAxisName == yAxisName;
  }

  @override
  int get hashCode {
    final List<Object?> values = <Object?>[
      widget,
      coordinateUnit,
      region,
      horizontalAlignment,
      verticalAlignment,
      x,
      y,
      xAxisName,
      yAxisName,
    ];
    return Object.hashAll(values);
  }
}
